﻿using Learun.Util;
using System;
using System.Data;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using Learun.Application.Organization;
using System.Linq;

namespace Learun.Application.TwoDevelopment.ZZDT_EC
{
    public class ec_accessBLL
    {
        ec_accessService ec_AccessService;
        public ec_accessBLL()
        {
            ec_AccessService = new ec_accessService();
        }
        public IEnumerable<ec_accessEntity> GetList(string queryJson, bool NeedLogin = true)
        {
            try
            {
                return ec_AccessService.GetList(queryJson, NeedLogin);
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowBusinessException(ex);
                }
            }
        }



        public List<string> GetAllUsersCanEditDrawing(string ProjectId, string DrawingID)
        {
            //var res = new ec_accessBLL().GetList("{ProjectId:\"" + ProjectId + "\",EntityID:\"" + DrawingID + "\", EntityTableID: \"ec_drawing_file\"}", false);// "{ProjectId:\"" + ProjectId + "\", EntityTableID: \"" + EntityTableID + "\"}"

            var res = new UserBLL().GetAllList().Where(x => x.F_UserId.ToUpper() != "SYSTEM");  //暂时都给权限
            List<string> res2 = new List<string>();
            foreach (var item in res)
            {
                res2.Add(item.F_RealName);
            }
            //res2.RemoveAt(new Random().Next(res2.Count - 1));  方便测试用
            return res2;
        }
    }
}
